package com.cdz.web.controller.bus;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cdz.common.annotation.Log;
import com.cdz.common.core.controller.BaseController;
import com.cdz.common.core.domain.AjaxResult;
import com.cdz.common.enums.BusinessType;
import com.cdz.bus.domain.BusToken;
import com.cdz.bus.service.IBusTokenService;
import com.cdz.common.utils.poi.ExcelUtil;
import com.cdz.common.core.page.TableDataInfo;

/**
 * 互通TOKEN管理Controller
 * 
 * @author guyi
 * @date 2024-11-17
 */
@RestController
@RequestMapping("/bus/busToken")
public class BusTokenController extends BaseController
{
    @Autowired
    private IBusTokenService busTokenService;

    /**
     * 查询互通TOKEN管理列表
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusToken busToken)
    {
        startPage();
        List<BusToken> list = busTokenService.selectBusTokenList(busToken);
        return getDataTable(list);
    }

    /**
     * 导出互通TOKEN管理列表
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:export')")
    @Log(title = "互通TOKEN管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusToken busToken)
    {
        List<BusToken> list = busTokenService.selectBusTokenList(busToken);
        ExcelUtil<BusToken> util = new ExcelUtil<BusToken>(BusToken.class);
        util.exportExcel(response, list, "互通TOKEN管理数据");
    }

    /**
     * 获取互通TOKEN管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busTokenService.selectBusTokenById(id));
    }

    /**
     * 新增互通TOKEN管理
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:add')")
    @Log(title = "互通TOKEN管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusToken busToken)
    {
        return toAjax(busTokenService.insertBusToken(busToken));
    }

    /**
     * 修改互通TOKEN管理
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:edit')")
    @Log(title = "互通TOKEN管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusToken busToken)
    {
        return toAjax(busTokenService.updateBusToken(busToken));
    }

    /**
     * 删除互通TOKEN管理
     */
    @PreAuthorize("@ss.hasPermi('bus:busToken:remove')")
    @Log(title = "互通TOKEN管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busTokenService.deleteBusTokenByIds(ids));
    }
}
